package 算法学习计划;

public class 第一个错误的版本 {

    public static int firstBadVersion(int n){

         int  mid = n / 2;
         int start = 0;
         int end = n;
         while (start < end){

             if (end - start == 1){
                 return end;
             }
             if (isBadVersion(mid)){
                 end = mid ;
                 mid = (end - start) / 2;
             }else {
                 start = mid;
                 mid = start + (end - start) / 2;
             }

         }
         return -1;
    }

    public static boolean isBadVersion(int version){
       return 11 <= version;
    }

    public static void main(String[] args) {
        System.out.println(firstBadVersion(10));
    }
}
